<?php
 // Ensure a valid runtime environment or die
  if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );

  // -- webMS Modification --
  // Check if osCommerce environment is already loaded
  if (defined( '_OSCOMMERCE_LOADED' )) {
    if (!DB_SHARED) {
      // Reconnect to osCommerce Database
      tep_db_connect() or die('Unable to connect to database server!');
    }
    // Load osCommerce Globals for Boxes
    global $category_links, $languages_id, $catID, $catID_array, $current_category_id;
    global $request_type, $lng, $cart, $currencies, $language, $navigation, $breadcrumb;
  } else {
    // Load osCommerce Environment for the First Time
    require('components/'.$option.'/includes/application_top.php');
  }
  require(DIR_WS_INCLUDES.'supplier_area_top.php');
  
	$cat = array(
				array(
					'title' => BOX_HEADING_SUPPLIERAREA,
					'image' => 'supplier.gif',
					'children' => array(
										array(
											'title' => BOX_HEADING_SUPPLIER_S_PRODUCTS,
											'link' => tep_href_link(FILENAME_SUPPLIER_S_CATEGORIES_PRODUCTS, 'selectbox=supplier&popup=popup')),
									array(
											'title' => BOX_HEADING_SUPPLIER_PRODUCT_ATTRIBS,
											'link' => tep_href_link(FILENAME_PRODUCTS_ATTRIBUTES, 'selectbox=supplier&popup=popup')),
										array(
											'title' => BOX_HEADING_SUPPLIER_STATISTIC,
											'link' => tep_href_link(FILENAME_SUPPLIER_STATISTIC, 'selectbox=supplier&popup=popup')),
											array(
											'title' => BOX_HEADING_SUPPLIER_VIEWED,
											'link' => tep_href_link(FILENAME_SUPPLIER_VIEWED, 'selectbox=supplier&popup=popup')),
										)
				)
		);
  $languages = tep_get_languages();
  $languages_array = array();
  $languages_selected = DEFAULT_LANGUAGE;
  for ($i = 0, $n = sizeof($languages); $i < $n; $i++) {
    $languages_array[] = array('id' => $languages[$i]['code'],
                               'text' => $languages[$i]['name']);
    if ($languages[$i]['directory'] == $language) {
      $languages_selected = $languages[$i]['code'];
    }
  }
  
  
?>
<table border="0" width="100%" cellspacing="0" cellpadding="2">
              <tr valign="top">
               
<?php
  $heading = array();
  $contents = array();
?>
                <td width="636" align="center" >
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
                          <tr>
                            <td class="contentheading">Supplier's Area </td>
                          </tr>
</table>
				</td>
                  </tr>
<?php
  $col = 2;
  $counter = 0;
  for ($i = 0, $n = sizeof($cat); $i < $n; $i++) {
    $counter++;
    if ($counter < $col) {
//      echo '                  <tr>' . "\n";
    }
    
    $cn = ($i >= 4 ? 2 : 1);
    
    ${'c' . $cn}.= '                    <table border="0" cellspacing="0" cellpadding="2">' . "\n" .
         '                      <tr>' . "\n" .
         '                        <td valign="top">' . tep_image(DIR_WS_IMAGES . 'categories/' . $cat[$i]['image'], $cat[$i]['title'], '283', '200') . '</td>' . "\n" .
         '                        <td><table border="0" cellspacing="0" cellpadding="2">' . "\n" .
         '                          <tr>' . "\n" .
         '                            <td class="main"></td>' . "\n" .
         '                          </tr>' . "\n" .
         '                          <tr>' . "\n" .
         '                            <td class="menusub">';

    $children = '';
    $children1 = '';
    $children2 = '';
    
    for ($j = 0, $k = sizeof($cat[$i]['children']); $j < $k; $j++) {
      
      if(isset($cat[$i]['cols'])) {
        if($j >= $cat[$i]['cols']) {
          $chn = 2;
        } else {
          $chn = 1;
        }
        ${'children'.$chn} .= '<a href="' . $cat[$i]['children'][$j]['link'] . '" class="menusub">' . $cat[$i]['children'][$j]['title'] . '</a><br>';
      } else {
        $children .= '<a href="' . $cat[$i]['children'][$j]['link'] . '" class="menusub">' . $cat[$i]['children'][$j]['title'] . '</a><br>';
      }
    }
    $children .= '<table><tr><td valign="top">' . $children1 . '</td><td valign="top">' . $children2 . '</td></tr></table>';
    
    
    ${'c' . $cn} .= $children;

    ${'c' . $cn} .='</td> ' . "\n" .
         '                          </tr>' . "\n" .
         '                        </table></td>' . "\n" .
         '                      </tr>' . "\n" .
         '                    </table>' . "\n";

    if ($counter >= $col) {
//      echo '                  </tr>' . "\n";
      $counter = 0;
    }
  }
?>

              <tr>
                <td valign="top">

                
                <?php echo $c1;?></td>
              </tr>

       
<?php require(DIR_WS_INCLUDES . 'footer.php'); ?>

</table></tr></td>
